<?php $url = new Url(); ?>
<div class="left">
    <?php $this->widget("AdminKetquaTrongngay")?>
    <?php $this->widget("AdminKetquaXoso")?>
</div>
<div class="right-main">
    <div class="righ-cont">
        <div class="right">
            <div class="title_style"> <span><b>Kết quả Xổ Số điện toán 6x36 trong ngày </b></span></div>
            <div class="tablestyle clearfix">
                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                    <tbody>
                        <tr>
                            <td><div class="table clearfix">
                                    <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                        <tbody>
                                            <tr class="bg_gray">
                                                <td colspan="6"><strong class="clblue">Mở thưởng ngày: <?=date("d/m/Y",time()) ?></strong></td>
                                            </tr>
                                            <tr>
                                                <td width="16%">
                                                    <b class="clblue"><input type="text" id="ketqua_1" value="<?=isset($row["ketqua_1"]) ? $row["ketqua_1"]:"" ?>" style="width: 60px;" /></b>
                                                    <span id="save1" ></span>
                                                </td>
                                                <td width="15%">
                                                    <b class="clblue"><input type="text" id="ketqua_2" value="<?=isset($row["ketqua_2"]) ? $row["ketqua_2"]:"" ?>" style="width: 60px;" /></b>
                                                    <span id="save2" ></span>
                                                </td>
                                                <td width="16%">
                                                    <b class="clblue"><input type="text" id="ketqua_3" value="<?=isset($row["ketqua_3"]) ? $row["ketqua_3"]:"" ?>" style="width: 60px;" /></b>
                                                    <span id="save3" ></span>
                                                </td>
                                                <td width="16%">
                                                    <b class="clblue"><input type="text" id="ketqua_4" value="<?=isset($row["ketqua_4"]) ? $row["ketqua_4"]:"" ?>" style="width: 60px;" /></b>
                                                    <span id="save4" ></span>
                                                </td>
                                                <td width="18%">
                                                    <b class="clblue"><input type="text" id="ketqua_5" value="<?=isset($row["ketqua_5"]) ? $row["ketqua_5"]:"" ?>" style="width: 60px;" /></b>
                                                    <span id="save5" ></span>
                                                </td>
                                                <td width="19%">
                                                    <b class="clblue"><input type="text" id="ketqua_6" value="<?=isset($row["ketqua_6"]) ? $row["ketqua_6"]:"" ?>" style="width: 60px;" /></b>
                                                    <span id="save6" ></span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="bg_yellow"><a class="save" href="javascript:void(0);" onclick="saveKetqua1();"> Save</a></td>
                                                <td class="bg_yellow"><a class="save" href="javascript:void(0);" onclick="saveKetqua2();"> Save</a></td>
                                                <td class="bg_yellow"><a class="save" href="javascript:void(0);" onclick="saveKetqua3();"> Save</a></td>
                                                <td class="bg_yellow"><a class="save" href="javascript:void(0);" onclick="saveKetqua4();"> Save</a></td>
                                                <td class="bg_yellow"><a class="save" href="javascript:void(0);" onclick="saveKetqua5();"> Save</a></td>
                                                <td class="bg_yellow"><a class="save" href="javascript:void(0);" onclick="saveKetqua6();"> Save</a></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div></td>
                            <td width="60"><a href="javascript:" onclick="saveKetquaAll()" class="next"></a></td>
                            <td><div class="table clearfix">
                                    <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                        <tbody>
                                            <tr class="bg_gray">
                                                <td colspan="6"><strong class="clblue">Mở thưởng ngày: <?=date("d/m/Y",time()) ?></strong></td>
                                            </tr>
                                            <tr>
                                                <td width="16%"><b class="clblue" id="kq1"><?=isset($row["ketqua_1"]) ? $row["ketqua_1"]:"&nbsp;"?></b></td>
                                                <td width="15%"><b class="clblue" id="kq2"><?=isset($row["ketqua_2"]) ? $row["ketqua_2"]:"&nbsp;"?></b></td>
                                                <td width="16%"><b class="clblue" id="kq3"><?=isset($row["ketqua_3"]) ? $row["ketqua_3"]:"&nbsp;"?></b></td>
                                                <td width="16%"><b class="clblue" id="kq4"><?=isset($row["ketqua_4"]) ? $row["ketqua_4"]:"&nbsp;"?></b></td>
                                                <td width="18%"><b class="clblue" id="kq5"><?=isset($row["ketqua_5"]) ? $row["ketqua_5"]:"&nbsp;"?></b></td>
                                                <td width="19%"><b class="clblue" id="kq6"><?=isset($row["ketqua_6"]) ? $row["ketqua_6"]:"&nbsp;"?></b></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var ngay_quay = '<?=date("d/m/Y",time()) ?>';
    function saveKetqua1(){
        var label = "ketqua_1";
        var ketqua = $("#ketqua_1").val();
        var divId1 = "save1";
        var divId2 = "kq1";
        saveKetqua(label,ketqua,divId1,divId2)
    }
    function saveKetqua2(){
        var label = "ketqua_2";
        var ketqua = $("#ketqua_2").val();
        var divId1 = "save2";
        var divId2 = "kq2";
        saveKetqua(label,ketqua,divId1,divId2)
    }
    function saveKetqua3(){
        var label = "ketqua_3";
        var ketqua = $("#ketqua_3").val();
        var divId1 = "save3";
        var divId2 = "kq3";
        saveKetqua(label,ketqua,divId1,divId2)
    }
    function saveKetqua4(){
        var label = "ketqua_4";
        var ketqua = $("#ketqua_4").val();
        var divId1 = "save4";
        var divId2 = "kq4";
        saveKetqua(label,ketqua,divId1,divId2)
    }
    function saveKetqua5(){
        var label = "ketqua_5";
        var ketqua = $("#ketqua_5").val();
        var divId1 = "save5";
        var divId2 = "kq5";
        saveKetqua(label,ketqua,divId1,divId2)
    }
    function saveKetqua6(){
        var label = "ketqua_6";
        var ketqua = $("#ketqua_6").val();
        var divId1 = "save6";
        var divId2 = "kq6";
        saveKetqua(label,ketqua,divId1,divId2)
    }
    function saveKetquaAll(){
        saveKetqua1();
        saveKetqua2();
        saveKetqua3();
        saveKetqua4();
        saveKetqua5();
        saveKetqua6();
    }
    function saveKetqua(label,ketqua,divId1,divId2){
        var strUrl = '<?=$url->createUrl("trongngay/saveDientoan6x36") ?>';

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                label:label,
                ketqua:ketqua,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#"+divId1).removeClass("loading");
                if(msg==1){                   
                    $("#"+divId1).html("OK");
                    $("#"+divId2).html(ketqua);                  
                }else{
                    $("#"+divId1).html("Loi");
                }       
            },
            beforeSend:function(){
                $("#"+divId1).html("");
                $("#"+divId1).addClass("loading");
            }
        });    

    }
</script>
